<template>
	<view>
		<h1>222</h1>
		<view class="container">
			<view v-for="(items, index) in currentsongs" :key="index">
				<view class="singer">
					<view class="singer-items">
						<view class="name">{{ items.name }}</view>
						<view class="icon">
							<u-icon name="play-circle" color="#000" size="28"></u-icon>
							<u-icon name="download" color="#000" size="28"></u-icon>
						</view>
					</view>
					<view class="ar">{{ items.ar[0].name }}</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { search_list, search_list_all } from '@/network/https/search.js';
export default {
	props: ['names'],
	data() {
		return {
			name: '',
			currentsongs: '',
			totalPage: 1, //有几页
			pageSize: 30, //每页几条
			currentPage: 1 //当前页数
		};
	},
	onLoad(val) {
		this.single();
	},
	created() {
		this.single();
	},
	onReachBottom() {
		console.log('触底');
		if (this.currentPage >= this.totalPage) return;
		this.single();
		console.log(this.$refs.li.names);
	},
	methods: {
		song() {
				
		},
		async single() {
			const parm = {
				keywords: this.names,
				limit: this.pageSize,
				offset: this.currentPage,
				type: 1
			};
			const { data: res } = await search_list_all(parm.keywords, parm.limit, parm.offset, parm.type);
			this.currentPage += 1;
			this.totalPage = res.songCount % 30;
			this.currentsongs = [...this.currentsongs, ...res.result.songs];
			console.log(res);
		}
	}
};
</script>
<style lang="scss" scoped>
.container {
	width: 700rpx;
	background-color: #ffffff;
	border-radius: 10rpx;
	margin: 30rpx auto;
	box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
	padding-bottom: 40rpx;
	.singer {
		&-items {
			display: flex;
			margin-left: 30rpx;
			padding-top: 20rpx;
			.name {
				width: 500rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				font-size: 28rpx;
			}
			.icon {
				display: flex;
				flex: 1;
				justify-content: flex-end;
			}
		}
		.ar {
			margin-left: 30rpx;
			font-size: 23rpx;
			color: #dd524d;
		}
	}
}
</style>
